package com.syni.mdd.sjb.common.component.utils.redis.config;

import io.lettuce.core.ReadFrom;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
import org.springframework.stereotype.Component;

/**
 * @className LuttuceReadFromConfig
 * @description TOO
 * @Author cfx
 * @DATE 2020/3/9 9:23
 * @VERSION 1.0
 **/
@Component
public class LuttuceReadFromConfig implements LettuceClientConfigurationBuilderCustomizer {
    @Override
    public void customize(LettuceClientConfiguration.LettuceClientConfigurationBuilder clientConfigurationBuilder) {
        //设置读优先读从机
        clientConfigurationBuilder.readFrom(ReadFrom.REPLICA_PREFERRED);
    }
}
